package AnnotationReflection;

import java.util.Arrays;

public class Test03 {

    public static void main(String[] args) throws ClassNotFoundException {
        //通过反射获取类的Class类
        //通过Class里面的众多方法可以获取User类中的信息
        Class c1 = Class.forName("AnnotationReflection.User");
        System.out.println("获取的类"+c1);

        //获取类名
        System.out.println("获取类名"+c1.getName());
        //获取类的方法
        System.out.println("获取类的方法"+Arrays.toString(c1.getMethods()));
        //获取类所在包
        System.out.println("获取类所在包"+c1.getPackage());
    }
}


class User{
    private String name;

    private Integer age;

    public User(){}

    public User(String name, Integer age) {
        this.name = name;
        this.age = age;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
